package com.shihb.principle.singlerposibility;/**
 *Description:
 *Version:1.0.0
 *@author shihb
 *@date 2020/6/23 20:45
 */
public class Demo2 {

  public static void main(String[] args) {
    LandAnimal animal = new LandAnimal();
    animal.run("金钱豹");
    AirAnimal airAnimal = new AirAnimal();
    airAnimal.run("鸟");
    WaterAnimal waterAnimal = new WaterAnimal();
    waterAnimal.run("鱼");
  }
}
/**
 *标准的单一职责，但改动了太大了，当方法很少时会显得和冗余
 * 所有当类的方法很少时可以用demo3
 */
class  LandAnimal {
  public void run(String animal){
    System.out.println(animal+"正在跑");
  }
}
class  AirAnimal {
  public void run(String animal){
    System.out.println(animal+"正在飞");
  }
}
class  WaterAnimal {
  public void run(String animal){
    System.out.println(animal+"正在游");
  }
}
